﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _13MultiTaskProg
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("1. Reversing digits.");
            Console.WriteLine("2. Average from array.");
            Console.WriteLine("3. Linear equation.");
            Console.Write("Select a task:");
            int choice = int.Parse(Console.ReadLine());
            if (choice == 1)
            {
                Console.Write("Enter an integer:");
                Console.WriteLine(ReverseDigits(int.Parse(Console.ReadLine())));
            }
            else if (choice == 2)
            {
                Console.Write("Array size:");
                int arraySize = int.Parse(Console.ReadLine());
                int[] array = new int[arraySize];
                for (int i = 0; i < array.Length; i++)
                {
                    Console.Write("array[{0}]:", i);
                    array[i] = int.Parse(Console.ReadLine());
                }
                Console.WriteLine("Average:{0}", ArrayAverage(array));
            }
            else if (choice == 3)
            {
                Console.WriteLine("ax+b = 0 solving for x:");
                Console.Write("a = ");
                double a = double.Parse(Console.ReadLine());
                Console.Write("b = ");
                double b = double.Parse(Console.ReadLine());
                Console.WriteLine("x = {0}",LinearEquation(a, b));
            }
        }
        static double LinearEquation(double a, double b)
        {
            double result = (-b) / a;
            return result;
        }
        static int ArrayAverage(int[] array)
        {
            int sum = 0;
            int average;
            for (int i = 0; i < array.Length; i++)
            {
                sum += array[i];
            }
            average = sum / array.Length;
            return average;
        }
        static string ReverseDigits(int number)
        {
            string strNumber = number.ToString();
            char[] array = strNumber.ToCharArray();
            Array.Reverse(array);
            return new string(array);
        }
    }
}
